package com.ryskoo.customer.applogin.repository;

import com.ryskoo.common.constant.CacheConstant;
import com.ryskoo.customer.applogin.domain.AppLoginTokenPO;
import com.ryskoo.framework.core.repository.BasicRedisImpl;
import com.ryskoo.framework.core.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;

/**
 * @author xman
 */
@Primary
@Repository
public class AppLoginTokenRedisImpl extends BasicRedisImpl<AppLoginTokenPO> implements IAppLoginTokenRepository {

	@Autowired
	private RedisUtil redisClient;

	@Autowired
	private IAppLoginTokenRepository appLoginTokenRepository;

	@PostConstruct
	public void init() {
		this.setRedisClient(redisClient);
		this.setDao(appLoginTokenRepository);
	}

	public AppLoginTokenRedisImpl() {
		super(CacheConstant.CUSTOMER_APP_TOKEN_KEY);
	}


	/**
	 * 根据 token和员工uuid 获取登录令牌
	 * @param token
	 * @param managerUuid
	 */
	@Override
	public AppLoginTokenPO getByTokenAndManager(String token,String managerUuid){
		return appLoginTokenRepository.getByTokenAndManager(token,managerUuid);
	}

}
